// check Data Change  parameter in master table is chkMasterUpdateRow and dataIsChange = 'N'
// type 	1 : execute
// 				2 : insert
//				3 : update
//				4 : delete

	var numDataChange= 0;
	function checkDataIsChange(index , obj , type)
	{ 
		if(master1.dataIsChange.length > 1 )
		{
			switch( type ) 
			{
				 case  1 :	 	
				 	checkDataChange(master1.masterExecute[index],master1.originalExecute[index] , master1.executeIsChange[index]);
					checkTextboxClick(1,master1.masterExecute[index] ,master1.executeIsChange[index] , master1.insertIsChange[index] , master1.originalUpdate[index] ,  master1.deleteIsChange[index],master1.masterExecute[index],master1.masterInsert[index],master1.masterUpdate[index],master1.masterDelete[index] )	 	;
				 	break;
				 	
				 case  2 :
				 	checkDataChange(master1.masterInsert[index],master1.originalInsert[index] , master1.insertIsChange[index]);
		 			checkTextboxClick(2,master1.masterInsert[index] ,master1.executeIsChange[index] , master1.insertIsChange[index] , master1.originalUpdate[index] ,  master1.deleteIsChange[index],master1.masterExecute[index],master1.masterInsert[index],master1.masterUpdate[index],master1.masterDelete[index] );
				 	break;
				 	
				 case  3 :
				 	checkDataChange(master1.masterUpdate[index],master1.originalUpdate[index] , master1.updateIsChange[index]);		 				
					checkTextboxClick(3,master1.masterUpdate[index],master1.executeIsChange[index] , master1.insertIsChange[index] , master1.originalUpdate[index] ,  master1.deleteIsChange[index],master1.masterExecute[index],master1.masterInsert[index],master1.masterUpdate[index],master1.masterDelete[index] )	 	;
				 	break;
				 	
				 case  4 :
				 	checkDataChange(master1.masterDelete[index],master1.originalDelete[index] , master1.deleteIsChange[index]);		 				
					checkTextboxClick(4,master1.masterDelete[index],master1.executeIsChange[index] , master1.insertIsChange[index] , master1.originalUpdate[index] ,  master1.deleteIsChange[index],master1.masterExecute[index],master1.masterInsert[index],master1.masterUpdate[index],master1.masterDelete[index] )	 ;
				 	break;
				 	
				 default:
			}//switch
			
			// Data in this record is change ?
			if( master1.executeIsChange[index].value == 'Y')
				master1.dataIsChange[index].value = 'Y';
			else if ( master1.insertIsChange[index].value == 'Y')
				master1.dataIsChange[index].value = 'Y';
			else if ( master1.updateIsChange[index].value == 'Y')
				master1.dataIsChange[index].value = 'Y';
			else if ( master1.deleteIsChange[index].value == 'Y')
				master1.dataIsChange[index].value = 'Y';
			else
				master1.dataIsChange[index].value = 'N';
//alert(master1.dataIsChange[index].value);
				
		}else{
			switch( type ) 
			{
				 case  1 :
				 	checkDataChange(master1.masterExecute,master1.originalExecute , master1.executeIsChange);	
					checkTextboxClick(1,master1.masterExecute,master1.executeIsChange , master1.insertIsChange , master1.originalUpdate ,  master1.deleteIsChange,master1.masterExecute,master1.masterInsert,master1.masterUpdate,master1.masterDelete )	 ;	 	
				 	break;
				 	
				 case  2 :
				 	checkDataChange(master1.masterInsert,master1.originalInsert , master1.insertIsChange);	
					checkTextboxClick(2,master1.masterInsert,master1.executeIsChange , master1.insertIsChange , master1.originalUpdate ,  master1.deleteIsChange,master1.masterExecute,master1.masterInsert,master1.masterUpdate,master1.masterDelete)	 ;	 	
				 	break;
				 	
				 case  3 :
				 	checkDataChange(master1.masterUpdate,master1.originalUpdate , master1.updateIsChange);		
					checkTextboxClick(3,master1.masterUpdate,master1.executeIsChange , master1.insertIsChange , master1.originalUpdate ,  master1.deleteIsChange,master1.masterExecute,master1.masterInsert,master1.masterUpdate,master1.masterDelete)	 ;	 	
				 	break;
				 	
				 case  4 :
				 	checkDataChange(master1.masterDelete,master1.originalDelete , master1.deleteIsChange);		
					checkTextboxClick(4,master1.masterDelete,master1.executeIsChange , master1.insertIsChange , master1.originalUpdate ,  master1.deleteIsChange,master1.masterExecute,master1.masterInsert,master1.masterUpdate,master1.masterDelete)	 ;	 	
				 	break;
				 	
				 default:
			}//switch
			
			// Data in this record is change ?
			if( master1.executeIsChange.value == 'Y')
			{
				master1.dataIsChange.value = 'Y';
			}else if ( master1.insertIsChange.value == 'Y'){
				master1.dataIsChange.value = 'Y';
			}else if ( master1.updateIsChange.value == 'Y'){
				master1.dataIsChange.value = 'Y';
			}else if ( master1.deleteIsChange.value == 'Y'){
				master1.dataIsChange.value = 'Y';
			}else{
				master1.dataIsChange.value = 'N';
			}
//alert(master1.dataIsChange.value);
		}// if
		
	}
	
// check master table manage menu checkbox click	
function checkTextboxClick(type , obj , exe , insert , up , del ,exeObj , insertObj  , upObj  , delObj )
{
		if ( obj.value == 'Y' )	
		{
			obj.value = 'N';
			obj.checked = false;
		}else{
			obj.value = 'Y';			
			obj.checked = true;
 		}		
 	 
		 switch( type)
	 	 {
	 	 	case 1 :
			  	 if(obj.checked == false)
			 	 {
	 	 			executeIsCheck( delObj , del ) ;
	 	 			executeIsCheck( upObj , up ) ;
	 	 			executeIsCheck( insertObj , insert ) ;
 				 }
	 	 		break;
	 	 	case 2 :
			  	 if(obj.checked == true)
					otherIsCheck( exeObj , exe);
	 	 		break;
	 	 	case 3 :
			  	 if(obj.checked == true)
					otherIsCheck( exeObj , exe);
	 	 		break;
	 	 	case 4 :
			  	 if(obj.checked == true)
					otherIsCheck( exeObj , exe);
	 	 		break;
	 	 	default :
	 	 }
}

function otherIsCheck( obj , original )
{
	if( original.value == 'Y' )
	{
		if( obj.checked == false )
		{
			obj.checked = true;
			original.value = 'N';
		}else{
			original.value = 'Y';
		}
	}else{
		if( obj.checked == false )
		{
			obj.checked = true;
			original.value = 'Y';
		}else{
			original.value = 'N';
		}
	}	
}

function executeIsCheck( obj , original )
{
	if( original.value == 'Y' )
	{
		if( obj.checked == true )
		{
			obj.checked = false;
			original.value = 'N';
		}
	}else{
		if( obj.checked == true )
		{
			obj.checked = false;
			original.value = 'Y';
		}
	}
	
}

function checkDataChange(obj , original , change)
{
	if ( obj.value == original.value )
	{
		change.value = 'Y';
	}else{
		change.value = 'N';			
	}
}	

function checkAllBox(objName){
  var checkBoxNode = document.getElementsByName(objName);
  var checkState = false;
  //alert(event.srcElement.checked + '  -' +checkBoxNode.length);
  for(var i=0;i<checkBoxNode.length;i++){
      checkBoxNode(i).checked = event.srcElement.checked ;
  }
}

function checkEachBox(chkName, chkAllName)
{
  var checkBoxNode  = document.getElementsByName(chkName) ;
  var chkboxAll     = eval('document.all.' + chkAllName) ;
  var checkState    = true ;
  for(var i=0;i<checkBoxNode.length;i++)
  {
    if ( !(checkBoxNode(i).checked) )
    {
      checkState = false ;
      break ;
    }
  }
  chkboxAll.checked = checkState ;
}

function checkBeforeDelete(chkName)
{
  var checkBoxNode  = document.getElementsByName(chkName) ;
  var checkState    = false ;
  for(var i=0;i<checkBoxNode.length;i++)
  {
    if (checkBoxNode(i).checked)
    {
      checkState = true ;
      break ;
    }
  }
  return checkState ;
}
